package view;

import model.User;
import util.SMSUtil;
import controller.AccountController;
import controller.Controller;
import controller.RuleController;

public class AdminView extends View {

	public AdminView(User user)
	{
		super(user);
	}
	
	@Override
	public void retrieveView() 
	{
		System.out.println("What do you wish to process ?\n1.Rules\n2.Accounts");
		
		String request = SMSUtil.getUserInput();
		if ((request.equals("1")) || (request.toLowerCase().contains("Rule")))
				{handleRules();}
		else
		if ((request.equals("2")) || (request.toLowerCase().contains("Account")))
				{handleAccounts();}
		else{
			System.out.println("Invalid choice!!");
		}
			
	}
	
	public void handleAccounts()
	{
		System.out.println("What do you wish to do with Account?\n1.Create\n2.Update\n3.Delete\n4.Retrieve");
		String accountAction = SMSUtil.getUserInput();
		Controller accountController = null;
		if(accountAction.equals("1")){
			accountController =  new AccountController("create");
		}else if(accountAction.equals("2")){
			accountController =  new AccountController("update");
		}else if(accountAction.equals("3")){
			accountController =  new AccountController("delete");
		}else if(accountAction.equals("4")){
			accountController =  new AccountController("retrieve");
		}else{
			System.out.println("Invalid choice!!");
		}
		
		accountController.handleRequest();
	}
	
	public void handleRules()
	{
		System.out.println("What do you wish to do with Rules ? \n1.Create\n2.Update \n3.Delete");
		String ruleAction = SMSUtil.getUserInput();
		Controller ruleController = null;
		if(ruleAction.equals("1")){
			ruleController =  new RuleController("create");
		}else if(ruleAction.equals("2")){
			ruleController =  new RuleController("update");
		}else if(ruleAction.equals("3")){
			ruleController =  new RuleController("delete");
		}else{
			System.out.println("Invalid choice!!");
		}
		ruleController.handleRequest();
	}
	
	
	
	}


